#ifndef SELECTIONBUFFER_H
#define SELECTIONBUFFER_H

#include <Ogre.h>

#include "SelectionMaterialSwitcher.h"
#include "SelectionRenderListener.h"

using namespace Ogre;

class SelectionMaterialSwitcher;
class SelectionRenderListener;

class SelectionBuffer
	{
	private:
		SceneManager *mSceneMgr;
		Camera *mCamera;
		RenderTarget *mRenderTarget;

		SelectionMaterialSwitcher *mMaterialSwitchListener;
		SelectionRenderListener *mSelectionTargetListener;

		TexturePtr mTexture;
		RenderTexture *mRenderTexture;
		uint8 *mBuffer;
		PixelBox *mPixelBox;
		Overlay *mSelectionDebugOverlay;

		void CreateRTTOverlays();
		void Update();
		void UpdateBufferSize();
		
	public:
		SelectionBuffer(SceneManager *sceneMgr, Camera* cam, RenderTarget *renderTarget);
		~SelectionBuffer();
	
		void clearBlackList();
		void pushToBlackList(Renderable*);
		void removeFromBlackList(Renderable*);
		
		Entity *OnSelectionClick(int x, int y);
		void ShowOverlay(bool show);
		inline TexturePtr getTexture() const { return mTexture; }
		
	};

#endif
